package com.EAIPClub.LiveStreamingManager.controller;

import com.EAIPClub.LiveStreamingManager.service.LiveStreamingManagerListService;
import com.EAIPClub.LiveStreamingManager.service.LiveStreamingManagerRTMPService;
import com.EAIPClub.LiveStreamingManager.service.LiveStreamingManagerWebRtcService;
import com.api.POJO.LiveStreamingManager.LiveStreamingManagerListInfo;
import com.api.POJO.LiveStreamingManager.LiveStreamingManagerListReturnMsg;
import com.api.POJO.LiveStreamingManager.LiveStreamingManagerReturnMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :
 * @Author :
 * @Date : 2021/12/9
 */
@RestController
public class LiveStreamingManagerController {

    private LiveStreamingManagerRTMPService rtmpService;
    @Autowired
    public void setRtmpService(LiveStreamingManagerRTMPService rtmpService) {
        this.rtmpService = rtmpService;
    }

    private LiveStreamingManagerWebRtcService webRtcService;

    @Autowired
    public void setWebRtcService(LiveStreamingManagerWebRtcService webRtcService) {
        this.webRtcService = webRtcService;
    }

    private LiveStreamingManagerListService liveStreamingManagerListService;

    @Autowired
    public void setLiveStreamingListService(LiveStreamingManagerListService liveStreamingManagerListService) {
        this.liveStreamingManagerListService = liveStreamingManagerListService;
    }

    @PostMapping("/live/add/info")
    public LiveStreamingManagerListReturnMsg addNewLiveStreamingListInfo(@RequestBody LiveStreamingManagerListInfo info){
        return liveStreamingManagerListService.addNewLiveStreamingInfo(info);
    }

    @DeleteMapping("/live/delete/info/{token}")
    public LiveStreamingManagerListReturnMsg deleteLiveStreamingListInfoByToken(@PathVariable String token){
        return liveStreamingManagerListService.deleteLiveStreamingInfoByToken(token);
    }

    @GetMapping("/live/add/rtmp/{token}")
    public LiveStreamingManagerReturnMsg addNewRTMPLiveStreamingInfo(@PathVariable String token){
        return rtmpService.addNewLiveStreaming(token);
    }

    @GetMapping("/live/get/rtmp/{token}")
    public LiveStreamingManagerReturnMsg getRTMPLiveStreamingInfoByToken(@PathVariable String token){
        return rtmpService.getRTMPLiveStreamingInfoByToken(token);
    }

    @DeleteMapping("/live/delete/rtmp/{token}")
    public LiveStreamingManagerReturnMsg deleteRTMPLiveStreamingInfo(@PathVariable String token) {
        return rtmpService.deleteNewLiveStreaming(token);
    }

    @GetMapping("/live/add/webrtc/{token}")
    public LiveStreamingManagerReturnMsg addNewWebRtcLiveStreamingInfo(@PathVariable String token){
        return webRtcService.addNewLiveStreaming(token);
    }

    @GetMapping("/live/get/webrtc/{token}")
    public LiveStreamingManagerReturnMsg getWebRtcLiveStreamingInfoByToken(@PathVariable String token){
        return webRtcService.getWebRtcLiveStreamingInfoByToken(token);
    }

    @DeleteMapping("/live/delete/webrtc/{token}")
    public LiveStreamingManagerReturnMsg deleteWebRtcLiveStreamingInfo(@PathVariable String token){
        return webRtcService.deleteNewLiveStreaming(token);
    }

    @GetMapping("/live/get/info/all")
    public LiveStreamingManagerListReturnMsg getAllLiveListInfo(){
        return liveStreamingManagerListService.getAllLiveStreamingList();
    }

    @GetMapping("/live/get/info/{token}")
    public LiveStreamingManagerListReturnMsg getLiveListInfoByToken(@PathVariable String token){
        return liveStreamingManagerListService.getLiveStreamingInfoByToken(token);
    }



}
